package com.jyw.business.comp.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.jyw.common.core.domain.CommonResult;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.jyw.common.annotation.Log;
import com.jyw.common.core.controller.BaseController;
import com.jyw.common.core.domain.AjaxResult;
import com.jyw.common.enums.BusinessType;
import com.jyw.business.comp.domain.CompScheduleShiftTime;
import com.jyw.business.comp.service.ICompScheduleShiftTimeService;
import com.jyw.common.utils.poi.ExcelUtil;
import com.jyw.common.core.page.TableDataInfo;

/**
 * 综合-班次时间Controller
 * 
 * @author ruoyi
 * @date 2023-12-25
 */
@RestController
@RequestMapping("/comp/time")
public class CompScheduleShiftTimeController extends BaseController
{
    @Autowired
    private ICompScheduleShiftTimeService compScheduleShiftTimeService;

    /**
     * 查询综合-班次时间列表
     */
    @PreAuthorize("@ss.hasPermi('comp:time:list')")
    @GetMapping("/list")
    public TableDataInfo<CompScheduleShiftTime> list(CompScheduleShiftTime compScheduleShiftTime)
    {
        startPage();
        List<CompScheduleShiftTime> list = compScheduleShiftTimeService.selectCompScheduleShiftTimeList(compScheduleShiftTime);
        return getDataTable(list);
    }

    /**
     * 导出综合-班次时间列表
     */
    @PreAuthorize("@ss.hasPermi('comp:time:export')")
    @Log(title = "综合-班次时间", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CompScheduleShiftTime compScheduleShiftTime)
    {
        List<CompScheduleShiftTime> list = compScheduleShiftTimeService.selectCompScheduleShiftTimeList(compScheduleShiftTime);
        ExcelUtil<CompScheduleShiftTime> util = new ExcelUtil<CompScheduleShiftTime>(CompScheduleShiftTime.class);
        util.exportExcel(response, list, "综合-班次时间数据");
    }

    /**
     * 获取综合-班次时间详细信息
     */
    @PreAuthorize("@ss.hasPermi('comp:time:query')")
    @GetMapping(value = "/{id}")
    public CommonResult<CompScheduleShiftTime> getInfo(@PathVariable("id") Long id)
    {
        return CommonResult.success(compScheduleShiftTimeService.selectCompScheduleShiftTimeById(id));
    }

    /**
     * 新增综合-班次时间
     */
    @PreAuthorize("@ss.hasPermi('comp:time:add')")
    @Log(title = "综合-班次时间", businessType = BusinessType.INSERT)
    @PostMapping
    public CommonResult add(@RequestBody CompScheduleShiftTime compScheduleShiftTime)
    {
        return CommonResult.success(compScheduleShiftTimeService.insertCompScheduleShiftTime(compScheduleShiftTime));
    }

    /**
     * 修改综合-班次时间
     */
    @PreAuthorize("@ss.hasPermi('comp:time:edit')")
    @Log(title = "综合-班次时间", businessType = BusinessType.UPDATE)
    @PutMapping
    public CommonResult edit(@RequestBody CompScheduleShiftTime compScheduleShiftTime)
    {
        return CommonResult.success(compScheduleShiftTimeService.updateCompScheduleShiftTime(compScheduleShiftTime));
    }

    /**
     * 删除综合-班次时间
     */
    @PreAuthorize("@ss.hasPermi('comp:time:remove')")
    @Log(title = "综合-班次时间", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public CommonResult remove(@PathVariable Long[] ids)
    {
        return CommonResult.success(compScheduleShiftTimeService.deleteCompScheduleShiftTimeByIds(ids));
    }
}
